package cn.itcast.ks.controller.v1;

import cn.itcast.ks.common.AppHttpCodeEnum;
import cn.itcast.ks.common.ResponseResult;
import cn.itcast.ks.pojo.dtos.NotWorkDto;
import cn.itcast.ks.pojo.dtos.ShowWorkDto;
import cn.itcast.ks.pojo.dtos.WorkDto;
import cn.itcast.ks.pojo.entity.Assignment;
import cn.itcast.ks.service.IAssignmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author wjs
 * @version 1.0
 * @date 2021/12/5 0005 下午 4:00
 */
@RestController
@RequestMapping("/v1/work")
public class WorkController {

    @Autowired
    private IAssignmentService assignmentService;

    @PostMapping("/findStudentWork")
    public ResponseResult findStudentWork(@RequestBody ShowWorkDto dto) {
        if (dto == null){
            return ResponseResult.errorResult(AppHttpCodeEnum.PARAM_REQUIRE);
        }
        return assignmentService.findStudentWork(dto);
    }

    @PostMapping("/showWorks")
    public ResponseResult showWorks(@RequestBody ShowWorkDto showWorkDto){

        if (showWorkDto == null){
            return ResponseResult.errorResult(AppHttpCodeEnum.PARAM_INVALID);
        }
        return assignmentService.showWorks(showWorkDto);
    }

    @PostMapping("/publishWork")
    public ResponseResult publishWork(@RequestBody WorkDto workDto){
        if (workDto == null){
            return ResponseResult.errorResult(AppHttpCodeEnum.PARAM_INVALID);
        }
        return assignmentService.publishWork(workDto);
    }

    @PostMapping("/findNotWorkByTime")
    public ResponseResult findNotWorkByTime(@RequestBody NotWorkDto notWorkDto){
        if (notWorkDto == null){
            return ResponseResult.errorResult(AppHttpCodeEnum.PARAM_INVALID);
        }
        return assignmentService.findNotWorkByTime(notWorkDto);
    }

}
